#!/bin/bash

#gphoto2 --force-overwrite --filename "start.%C" --capture-image-and-download


#output path

#output filename

#hold time
holdtime=1s

#wait time
waittime=3s





#capture count
capturecount=0

function zoom {
	
	#$1 = number of steps
	#$2 = step direction
	
	command="gphoto2 --force-overwrite --capture-preview"
	
	for i in `seq 1 $1`;
	do
		command="$command --set-config manualfocusdrive=$2"
	done
	
	$command
	
}

function zoom_and_capture {
	
	#$1 = number of steps
	#$2 = step direction
	#$3 = hold time
	#$4 = wait time
	
	zoom $1 $2
	
	capturecount=$[capturecount + 1]
	
	gphoto2 --force-overwrite --filename "output_$capturecount.%C" \
	--set-config eosremoterelease=Immediate \
	--wait-event=$3 \
	--set-config eosremoterelease=Off \
	--wait-event-and-download=$4
	
}

function capture_no_af {
	
	#$1 = hold time
	#$2 = wait time
	
	capturecount=$[capturecount + 1]
	
	gphoto2 --force-overwrite --filename "output_$capturecount.%C" \
	--set-config eosremoterelease=Immediate \
	--wait-event=$1 \
	--set-config eosremoterelease=None \
	--wait-event-and-download=$2
		
}

function capture_tv {
	
	#$1 = tv
	#$3 = wait time
	 
	capturecount=$[capturecount + 1]
	
	#/main/settings/capturetarget
	
	gphoto2  \
	--quiet \
	--force-overwrite \
	--filename "output_$capturecount.%C" \
	--set-config shutterspeed=$1 \
	--set-config eosremoterelease=Immediate \
	--set-config eosremoterelease=None \
	--wait-event-and-download=$2
	
}



for i in `tac ./shutterspeedsfast.data`;
do
	echo capturing $i
	capture_tv $i 5s
done


for i in `tac ./shutterspeedsslow.data`;
do
	echo capturing $i
	capture_tv $i `echo "scale=0;$i+5" | bc`s
done


for i in `seq 1 30`;
do
	echo capturing middle $i
	capture_tv 30 35s
done


for i in `cat ./shutterspeedsslow.data`;
do
	echo capturing $i
	capture_tv $i `echo "scale=0;$i+5" | bc`s
done

for i in `cat ./shutterspeedsfast.data`;
do
	echo capturing $i
	capture_tv $i 5s
done




exit


